package com.team2.outpatient_sys.dao;

import com.team2.outpatient_sys.pojo.Patient;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PatientDao {
    //新建病人信息
    @Insert("insert into patient values(null,#{name},#{idCard},#{gender},#{birth},#{phone},#{address})")
    public int add(Patient patient);
    //修改病人信息
    @Update("update patient set phone=#{phone},address=#{address} where id=#{id}")
    public int update(Patient patient);
    //查询用户所绑定的病人
    @Select("select * from patient p,user_patient up where p.id=up.patient_id and up.user_id = #{uid}")
    public List<Patient> findByUid(int uid);
    //根据身份证查询病人
    @Select("select * from patient where id_card=#{idCard}")
    public Patient findByIdCard(String idCard);


    @Select("select * from patient where id=#{id}")
    public Patient findById(int id);
}
